package com.py.custom.common.web.valid.annotation;

import com.py.custom.common.web.valid.CustomValidHandler;
import com.py.custom.common.web.valid.constraint.CustomValidConstraint;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * description：自定义校验参数注解
 *
 * @author pengyou
 * @version 1.0.0
 * @date 2021/10/23
 */
@Target(value = {ElementType.FIELD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
// 当前自定义的参数校验注解，对应的处理类
@Constraint(validatedBy = CustomValidConstraint.class)
public @interface CustomValid {

    /**
     * 实际校验处理类
     *
     * @return
     */
    Class<? extends CustomValidHandler<?>> handler();

    /**
     * 校验返回提示信息
     *
     * @return
     */
    String message() default "校验失败";

    /**
     * 校验分组
     *
     * @return
     */
    Class<?>[] groups() default {};

    /**
     * 校验负载
     *
     * @return
     */
    Class<? extends Payload>[] payload() default {};
}
